package com.newidea.jiangong.dto;

import com.newidea.jiangong.utils.HeatFacilityUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;
import java.util.Map;

@Schema(title = "供热系统")
@Data
public class HeatSys {

    @Schema(title = "采集时间")
    private String collectDate;

    @Schema(title = "室外温度")
    private String outdoorTemperature;

    @Schema(title = "供水额定功率")
    private String supplyRatedPower;

    @Schema(title = "总回水温度 = 大屯的一次供水温度")
    private String totalReturnTemperature;

    @Schema(title = "总回水压力 = 大屯的一次供水压力")
    private String totalReturnPressure;

    @Schema(title = "支一供水温度")
    private String oneSupplyTemperature;

    @Schema(title = "支一供水压力")
    private String oneSupplyPressure;

    @Schema(title = "支一供水流量")
    private String oneSupplyQuantity;

    @Schema(title = "支二供水温度")
    private String twoSupplyTemperature;

    @Schema(title = "支二供水压力")
    private String twoSupplyPressure;

    @Schema(title = "支二供水流量")
    private String twoSupplyQuantity;

    @Schema(title = "循环泵前水压力")
    private String cyclePumpFrontPressure;

    @Schema(title = "循环泵泵后压力")
    private String cyclePumpRearPressure;

    @Schema(title = "软化水箱液位")
    private String softenCisternLiquid;

    @Schema(title = "除氧水箱液位")
    private String deoxidizeCisternLiquid;

    @Schema(title = "总燃气用量")
    private String totalFuelGasDosage;

    @Schema(title = "自来水流量")
    private String tapWaterQuantity;

    /**
     * 创建供热系统实体
     *
     * @param facilityMap    设备地址:值
     * @param sysAddressList 系统设备地址集合
     * @return 供热系统实体
     */
    public static HeatSys createHeatSys(Map<String, String> facilityMap, List<String> sysAddressList) {
        // 地址角标，facilityMap每取一次都要加1
        int index = 0;
        // 供热系统
        HeatSys headSys = new HeatSys();
        // 系统供水额定功率
        headSys.setSupplyRatedPower(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index++));
        // 系统总回水温度 = 一次供水温度
        headSys.setTotalReturnTemperature(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index++));
        // 系统总回水压力 = 一次供水压力
        headSys.setTotalReturnPressure(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index++));
        // 系统支一供水温度
        headSys.setOneSupplyTemperature(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index++));
        // 系统支一供水压力
        headSys.setOneSupplyPressure(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index++));
        // 系统支一供水流量
        headSys.setOneSupplyQuantity(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index++));
        // 系统支二供水温度
        headSys.setTwoSupplyTemperature(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index++));
        // 系统支二供水压力
        headSys.setTwoSupplyPressure(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index++));
        // 系统支二供水流量
        headSys.setTwoSupplyQuantity(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index++));
        // 系统循环泵前水压力
        headSys.setCyclePumpFrontPressure(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index++));
        // 系统循环泵泵后压力
        headSys.setCyclePumpRearPressure(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index++));
        // 软化水箱液位
        headSys.setSoftenCisternLiquid(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index++));
        // 除氧水箱液位
        headSys.setDeoxidizeCisternLiquid(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index++));
        // 总燃气用量
        headSys.setTotalFuelGasDosage(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index++));
        // 自来水流量
        headSys.setTapWaterQuantity(HeatFacilityUtil.getStateName(facilityMap, sysAddressList, index));
        return headSys;
    }
}
